<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="斯坦福李飞飞教授计算机视觉课程笔记, study">
    <meta name="description" content="本文知识列举了一些我认为比较重要的点，有很多局限性与不足之处，该课程的参考笔记看查看“相关资料”。
一、图像分类——数据驱动方法图像中对于目标物的遮挡、背景色、运动等情况，都要求识别的算法需要有良好的鲁棒性；
识别图像的时候有一种思路是利用">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="referrer" content="no-referrer-when-downgrade">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>斯坦福李飞飞教授计算机视觉课程笔记 | 今夕清欢</title>
    
    <link rel="stylesheet" type="text/css" href="/libs/artitalk/artitalk.min.css">


    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery-3.6.0.min.js"></script>

<meta name="generator" content="Hexo 5.4.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
<link rel="alternate" href="/atom.xml" title="今夕清欢" type="application/atom+xml">
</head>




<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">今夕清欢</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">今夕清欢</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/13.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">斯坦福李飞飞教授计算机视觉课程笔记</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">
                                <span class="chip bg-color">机器学习</span>
                            </a>
                        
                            <a href="/tags/Python/">
                                <span class="chip bg-color">Python</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/" class="post-category">
                                机器学习
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2021-11-13
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2021-11-13
                </div>
                

                

                

                
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/libs/prism/prism.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <p>本文知识列举了一些我认为比较重要的点，有很多局限性与不足之处，该课程的参考笔记看查看“相关资料”。</p>
<h3 id="一、图像分类——数据驱动方法"><a href="#一、图像分类——数据驱动方法" class="headerlink" title="一、图像分类——数据驱动方法"></a>一、图像分类——数据驱动方法</h3><p>图像中对于目标物的遮挡、背景色、运动等情况，都要求识别的算法需要有良好的鲁棒性；</p>
<p>识别图像的时候有一种思路是利用图形的边缘信息能够反映信息的特点，比如一个猫的图片中，可以看出这些线条反映出这是一种猫。(就像我们的简笔画一样，用简单的几条线条，来画一只猫、狗···)</p>
<p><img src="http://image.lijitao.top/%E7%94%A8%E7%BA%BF%E6%9D%A1%E6%9D%A5%E8%A1%A8%E7%A4%BA%E7%8C%AB.PNG"></p>
<p>但是这只能是针对猫的算法，如果换成另一个实体，算法就会失效。采用数据驱动的方式，可以解决这个问题。</p>
<p>通过搜集大量预先已经标记好的数据集，输入给机器后，机器用”某种方式“生成一个模型，使用它就能识别这些种类的实体。</p>
<p>我们的API就变成了这样：</p>
<p><strong>训练函数：</strong>用来接收图片和标签，然后输出模型；</p>
<pre class="line-numbers language-python" data-language="python"><code class="language-python"><span class="token keyword">def</span> <span class="token function">train</span><span class="token punctuation">(</span>images<span class="token punctuation">,</span>labels<span class="token punctuation">)</span><span class="token punctuation">:</span>
    <span class="token comment">#Machine learning!</span>
    <span class="token keyword">return</span> model<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>

<p><strong>预测函数：</strong>接收这个模型，对图片种类进行预测。</p>
<pre class="line-numbers language-python" data-language="python"><code class="language-python"><span class="token keyword">def</span> <span class="token function">predict</span><span class="token punctuation">(</span>model<span class="token punctuation">,</span> test_images<span class="token punctuation">)</span><span class="token punctuation">:</span>
    <span class="token comment">#Use model to predict labels</span>
    <span class="token keyword">return</span> test_labels<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>

<p>正是采用了这种方法，图形识别领域的进步很大。这种数据驱动的算法是比深度学习更广义的一种理念。</p>
<p>对比图片的方法（曼哈顿距离）：</p>
<h3 id="二、K最近邻算法-KNN-："><a href="#二、K最近邻算法-KNN-：" class="headerlink" title="二、K最近邻算法(KNN)："></a>二、K最近邻算法(KNN)：</h3><p>曼哈顿距离L1（像素之间绝对值的总和）：</p>
<p><img src="http://image.lijitao.top/%E5%AF%B9%E6%AF%94%E5%9B%BE%E7%89%87%E7%9A%84%E6%96%B9%E6%B3%95.PNG"></p>
<p>Q: N个实例的训练和测试速度有多快？</p>
<p>A：训练 O(1)    测试O(N)</p>
<p>测试的时候只需要存储数据，无论数据集多大，都是一个恒定的时间（待理解）</p>
<p>测试需要将数据集的N个训练实例与测试对比，是一个很慢的过程。</p>
<p>而在实际应用中我们的期望与之相反。</p>
<p>实际应用中最近邻算法的表现：</p>
<p><img src="http://image.lijitao.top/%E6%9C%80%E8%BF%91%E9%82%BB%E7%AE%97%E6%B3%95%E7%9A%84%E5%AE%9E%E9%99%85%E8%A1%A8%E7%8E%B0.PNG"></p>
<p>欧式距离L2（取平方和的平方根，并把它作为距离）：</p>
<p><img src="http://image.lijitao.top/L1%E5%92%8CL2%E7%9A%84%E5%AF%B9%E6%AF%94.PNG"></p>
<p>L1受坐标轴的影响，坐标轴改变，两点间的L1距离（可能）也会改变，而L2不受影响。</p>
<p>L1更合适：如果你输入的特征向量中的一些值，有些重要意义（比如员工的姓名、工资、年龄···数据有着对应关系时）</p>
<p>L2更合适：这个向量只是通用向量，不知道其中元素的含义</p>
<p>具体问题可以都尝试一下，找出最适合的。</p>
<p>KNN可视化演示：<a target="_blank" rel="noopener" href="http://vision.stanford.edu/teaching/cs231n-demos/knn/">http://vision.stanford.edu/teaching/cs231n-demos/knn/</a></p>
<p>KNN可视化代码实现：<a target="_blank" rel="noopener" href="https://blog.csdn.net/u014556057/article/details/81286608">https://blog.csdn.net/u014556057/article/details/81286608</a></p>
<p><strong>超参数：</strong>K 和距离度量，不一定都能从训练数据中学到，人为提前的做出设定。这些参数是以来与具体问题的，尝试修改超参数并找出解决具体问题最合适的那一组。</p>
<p><img src="http://image.lijitao.top/%E8%B6%85%E5%8F%82%E7%9A%84%E9%80%89%E5%8F%96.PNG"></p>
<p><del>Idea #1</del>： K = 1 总是最完美的，K取更大的值会出现一些错误，但是对于训练集中未出现的数据分类性能更佳。</p>
<p><del>Idea #2</del>： 训练集和测试集选择不同的超参，可能会尝试出一组比较好的超参，但这样做是没有意义的。</p>
<p>Idea #3： 大部分数据做训练集，然后建立一个验证集和一个测试集。训练集用不同的超参来训练算法，在验证集上进行评估，然后通过这种方式找出表现最好的一组超参。完成这一切后，把表现最好的分类器拿出来，在测试集上跑一跑，<strong>这才是你要写到论文中的数据</strong>。  这个才能表现出你的算法在未见的数据集上的表现如何。</p>
<p><img src="http://image.lijitao.top/K%E5%80%BC%E7%9A%84%E9%80%89%E5%8F%96%E4%B8%8E%E5%87%86%E7%A1%AE%E7%8E%87.PNG"></p>
<p><strong>交叉验证：</strong>小数据集中更常用而深度学习中不那么常用。首先预留测试训练集，剩余数据分为五份，四份训练，一份验证，依次交换次序，选出更好的超参。</p>
<p><img src="http://image.lijitao.top/%E4%BA%A4%E5%8F%89%E9%AA%8C%E8%AF%81.PNG"></p>
<p>KKN用来处理图像并不合适：</p>
<p><img src="http://image.lijitao.top/KNNL2%E5%BD%A2%E5%90%8C%E7%9A%84%E5%80%BC.PNG"></p>
<p>三张图片有着形同的L2值，L2很难表现图像之间的数据感知差异。</p>
<p><strong>维度灾难</strong>：训练所需要的计算随着维度的增加而指数上升。</p>
<p><img src="http://image.lijitao.top/%E7%BB%B4%E5%BA%A6%E7%81%BE%E9%9A%BE.PNG"></p>
<h3 id="三、线性分类"><a href="#三、线性分类" class="headerlink" title="三、线性分类"></a>三、线性分类</h3><p>  线性分类就像是乐高中的基础模块，它通过把图片拉伸成长向量（公式中的x），参数矩阵W作为列向量，把它们作为输入。</p>
<p><img src="http://image.lijitao.top/1.PNG">)</p>
<p>然后它们会转换成10个数字评分，这十分数字评分就对应了图片在下图中十个数据集里的评分（评分越高就越有可能是这个分类），线性分类器可以解释成每个种类的学习模板。不同的数据集种类的数量会影响偏执值。</p>
<p><img src="http://image.lijitao.top/2.%E7%BA%BF%E6%80%A7%E5%88%86%E7%B1%BB%E7%9A%84%E5%AE%9E%E4%BE%8B.PNG"></p>
<p><img src="http://image.lijitao.top/3%E7%BA%BF%E6%80%A7%E5%88%86%E7%B1%BB%E5%8E%9F%E7%90%86.PNG"></p>
<p>线性分类器难以解决的问题：奇数和偶数的问题  、多分类问题（一个类别出现在不同的领域空间中，比如上述案例中的马匹朝左右两边看会被生成一个两个头的模型）、 </p>
<p><img src="http://image.lijitao.top/4%E7%BA%BF%E6%80%A7%E5%88%86%E7%B1%BB%E5%99%A8%E9%9A%BE%E4%BB%A5%E8%A7%A3%E5%86%B3%E6%8A%80%E6%9C%AF%E5%92%8C%E5%81%B6%E6%95%B0%E7%9A%84%E9%97%AE%E9%A2%98.PNG"></p>
<p>线性分类器基础概念详解：    <a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_38278334/article/details/82831541">link1</a>        <a target="_blank" rel="noopener" href="https://www.cnblogs.com/xuanyuyt/p/5993982.html">link2</a></p>
<h3 id="四、损失函数及其优化"><a href="#四、损失函数及其优化" class="headerlink" title="四、损失函数及其优化"></a>四、损失函数及其优化</h3><p><strong>铰链损失函数、交叉熵损失函数：</strong>    <a target="_blank" rel="noopener" href="https://blog.csdn.net/fendegao/article/details/79968994">link</a></p>
<p><strong>W值的选取：</strong></p>
<p>可以通过人为的观察数据来选取，但更明智的方法是采用损失函数来评估W的表现。</p>
<p>SVM损失函数：把W值当做输入，根据得分来定量的衡量W值的表现。</p>
<p>代码实现：</p>
<pre class="line-numbers language-python" data-language="python"><code class="language-python"><span class="token keyword">def</span> <span class="token function">L_i_vectorized</span><span class="token punctuation">(</span>x<span class="token punctuation">,</span> y<span class="token punctuation">,</span> W<span class="token punctuation">)</span><span class="token punctuation">:</span>
    scores <span class="token operator">=</span> w<span class="token punctuation">.</span>dot<span class="token punctuation">(</span>x<span class="token punctuation">)</span>
    margins <span class="token operator">=</span> np<span class="token punctuation">.</span>maximum<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> scores <span class="token operator">-</span> scores<span class="token punctuation">[</span>y<span class="token punctuation">]</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span>
    margins<span class="token punctuation">[</span>y<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">0</span>
    loss_i <span class="token operator">=</span> np<span class="token punctuation">.</span><span class="token builtin">sum</span><span class="token punctuation">(</span>margins<span class="token punctuation">)</span>
    <span class="token keyword">return</span> loss_i<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<p><img src="http://image.lijitao.top/%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0%E7%9A%84%E8%AE%A1%E7%AE%97%E5%8E%9F%E7%90%86.PNG"></p>
<p>损失函数计算图</p>
<p><img src="http://image.lijitao.top/%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0%E7%9A%84%E8%AE%A1%E7%AE%97%E5%9B%BE.PNG"></p>
<p>相关概念：对数似然函数（<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1K7411W7So?t=1357&amp;p=3">链接</a>35:00）</p>
<p><strong>优化损失函数：</strong></p>
<p>方法一：随机选择权重，猜出一个比较合适的值，但这种方法比较不稳定（<strong>论文思路</strong>）</p>
<p>方法二：求导，就像下山一样，随着坡度向下</p>
<p><img src="http://image.lijitao.top/%E6%8D%95%E8%8E%B7.PNG" alt=" "></p>
<p>实际情况中常使用解析解，使用数值解来进行检查。</p>
<pre class="line-numbers language-python" data-language="python"><code class="language-python"><span class="token comment">#Vanilla Gradient Descent</span>
<span class="token keyword">while</span> true<span class="token punctuation">:</span>
    weights_grad <span class="token operator">=</span> evaluate_gradient<span class="token punctuation">(</span>loss_fun<span class="token punctuation">,</span> data<span class="token punctuation">,</span> weights<span class="token punctuation">)</span>
    weights <span class="token operator">+=</span> <span class="token operator">-</span> step_size <span class="token operator">*</span> weights_grad    <span class="token comment">#perform parameter update</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></code></pre>

<p>step_size如果过小会导致训练时间太长，效率低；step_size如果过大则会导致振荡甚至找不到最优点。（动态演示见斯坦福大学课程官网网页）</p>
<p>Stochastic Gradient Descent(SGD)优化器弊端：容易陷入局部良好的点，但不是所求的最优点。</p>
<p>当数据集过于庞大时，可以分步一点点的“喂”（一般约定俗成为2的指数个）：</p>
<pre class="line-numbers language-python" data-language="python"><code class="language-python"><span class="token comment">#Vanilla Minibatch Gradient Descent</span>
<span class="token keyword">while</span> <span class="token boolean">True</span><span class="token punctuation">:</span>
    data_batch <span class="token operator">=</span> sample_training_data<span class="token punctuation">(</span>data<span class="token punctuation">,</span> <span class="token number">256</span><span class="token punctuation">)</span>	<span class="token comment">#sample 256 examples</span>
    weights_grad <span class="token operator">=</span> evaluate_gradint<span class="token punctuation">(</span>loss_fun<span class="token punctuation">,</span> data_batch<span class="token punctuation">,</span> weights<span class="token punctuation">)</span>
    weights <span class="token operator">+=</span> <span class="token operator">-</span> step_size <span class="token operator">*</span> weights_grad 	<span class="token comment">#perform parameterdate</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<p>深度学习模型例如卷积神经网络不需要人为的构建特征，只需要喂给这些系统大量的数据，便能通过一些列的卷积和其他运算中自动勾践某一个类的特征。（数据驱动）</p>
<p>传统计算机视觉算法：HOG、SIGT特征提取（需要人为的构建特征）</p>
<p>深度学习算法：CNN（端到端、数据驱动、学习得到特征）</p>
<h3 id="五、神经网络"><a href="#五、神经网络" class="headerlink" title="五、神经网络"></a>五、神经网络</h3><p><strong>激活函数</strong>: 让一个线性分类器产生一个非线性输出（sigmoid、tanh、ReL、Maxout、ELU）</p>
<p>如果没有非线性激活函数，无论堆叠多少层都是线性的</p>
<p><strong>反向传播：</strong></p>
<p>通过计算图可以利用反向传播技术递归的调用链式法则来计算计算图中每个变量的梯度。</p>
<p>两层的神经网络代码：</p>
<pre class="line-numbers language-python" data-language="python"><code class="language-python"><span class="token keyword">import</span> numpy <span class="token keyword">as</span> np
<span class="token keyword">from</span> numpy<span class="token punctuation">.</span>random <span class="token keyword">import</span> randn

N<span class="token punctuation">,</span> D_in<span class="token punctuation">,</span> H<span class="token punctuation">,</span> D_out <span class="token operator">=</span> <span class="token number">64</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">,</span> <span class="token number">10</span>
x<span class="token punctuation">,</span> y <span class="token operator">=</span> randn<span class="token punctuation">(</span>N<span class="token punctuation">,</span> D_in<span class="token punctuation">)</span><span class="token punctuation">,</span> randn<span class="token punctuation">(</span>N<span class="token punctuation">,</span> D_out<span class="token punctuation">)</span>
w1<span class="token punctuation">,</span> w2 <span class="token operator">=</span> randn<span class="token punctuation">(</span>D_in<span class="token punctuation">,</span> H<span class="token punctuation">)</span><span class="token punctuation">,</span> randn<span class="token punctuation">(</span>H<span class="token punctuation">,</span> D_out<span class="token punctuation">)</span>

<span class="token keyword">for</span> t <span class="token keyword">in</span> <span class="token builtin">range</span><span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
   h <span class="token operator">=</span> <span class="token number">1</span> <span class="token operator">/</span> <span class="token punctuation">(</span><span class="token number">1</span> <span class="token operator">+</span> np<span class="token punctuation">.</span>exp<span class="token punctuation">(</span><span class="token operator">-</span>x<span class="token punctuation">.</span>dot<span class="token punctuation">(</span>w1<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
   y_pred <span class="token operator">=</span> h<span class="token punctuation">.</span>dot<span class="token punctuation">(</span>w2<span class="token punctuation">)</span>
   loss <span class="token operator">=</span> np<span class="token punctuation">.</span>square<span class="token punctuation">(</span>y_pred <span class="token operator">-</span> y<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token builtin">sum</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
   <span class="token keyword">print</span><span class="token punctuation">(</span>t<span class="token punctuation">,</span> loss<span class="token punctuation">)</span>

   grad_y_pred <span class="token operator">=</span> <span class="token number">2.0</span> <span class="token operator">*</span> <span class="token punctuation">(</span>y_pred <span class="token operator">-</span> y<span class="token punctuation">)</span>
   grad_w2 <span class="token operator">=</span> h<span class="token punctuation">.</span>T<span class="token punctuation">.</span>dot<span class="token punctuation">(</span>grad_y_pred<span class="token punctuation">)</span>
   grad_h <span class="token operator">=</span> grad_y_pred<span class="token punctuation">.</span>dot<span class="token punctuation">(</span>w2<span class="token punctuation">.</span>T<span class="token punctuation">)</span>
   grad_w1 <span class="token operator">=</span> x<span class="token punctuation">.</span>T<span class="token punctuation">.</span>dot<span class="token punctuation">(</span>grad_h <span class="token operator">*</span> h <span class="token operator">*</span> <span class="token punctuation">(</span><span class="token number">1</span> <span class="token operator">-</span> h<span class="token punctuation">)</span><span class="token punctuation">)</span>

   w1 <span class="token operator">-=</span> <span class="token number">1e-4</span> <span class="token operator">*</span> grad_w1
   w2 <span class="token operator">-=</span> <span class="token number">1e-4</span> <span class="token operator">*</span> grad_w2<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>



<p><strong>卷积神经网络(CNN):</strong> 它与常规神经网络的构想基本一致，不同的是需要训练卷积层，因为卷积层能够更好的保留输入的空间结构。</p>
<p>过程：卷积 —&gt; 下采样（池化）—&gt; 全连接</p>
<p>卷积层进行特征的抽取，池化层进行泛化，全连接层把提取到的各种特征进行汇总和交融。</p>
<p><img src="http://image.lijitao.top/%E5%8D%B7%E7%A7%AF%E7%9A%84%E8%BF%87%E7%A8%8B.PNG"></p>
<p>这些层采用多个卷积核，每个卷积核会产生一个激活映射，来作为下一层的输入：</p>
<p><img src="http://image.lijitao.top/%E5%8D%B7%E7%A7%AF%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C%E5%A4%9A%E4%B8%AA%E5%8D%B7%E7%A7%AF%E5%9D%97%E5%B7%A5%E4%BD%9C%E7%A4%BA%E6%84%8F%E5%9B%BE.PNG"></p>
<p>采用多层卷积层池化层能够丰富得到的信息：</p>
<p><img src="http://image.lijitao.top/%E5%A4%9A%E5%B1%82%E5%8D%B7%E7%A7%AF%E5%AF%B9%E4%B8%B0%E5%AF%8C%E5%BE%97%E5%88%B0%E7%9A%84%E7%89%B9%E5%BE%81.PNG"></p>
<p>如果不进行边缘填补，同时又存在多层神经网络时，会导致逐层缩小，会损失大量信息。填补0虽然是人为，但是不会改变图片本身的信息。</p>
<p>卷积过程可视化页面:     <a target="_blank" rel="noopener" href="https://github.com/thomelane/thomelane.github.io">页面1</a>    <a target="_blank" rel="noopener" href="https://ezyang.github.io/convolution-visualizer/index.html">页面2</a></p>
<p>为什么要进行卷积：</p>
<p>卷积核其实就相当于定义了一个特征，卷积的过程可以检测图像每个部分与卷积核定义特征的相似程度（示意图<a target="_blank" rel="noopener" href="http://image.lijitao.top/%E5%AF%B9%E5%9B%BE%E5%83%8F%E8%BF%9B%E8%A1%8C%E5%8D%B7%E7%A7%AF%E5%A4%84%E7%90%86%E7%9A%84%E5%8E%9F%E5%9B%A0.PNG">链接</a>），也可以利用以下方式来模糊和检测边缘：</p>
<p><img src="http://image.lijitao.top/%E5%AF%B9%E5%9B%BE%E5%83%8F%E8%BF%9B%E8%A1%8C%E5%8D%B7%E7%A7%AF%E5%A4%84%E7%90%86%E7%9A%84%E5%8E%9F%E5%9B%A02.PNG"></p>
<p>不同的卷积核能够提取图片不同的特征：</p>
<p><img src="http://image.lijitao.top/%E4%B8%8D%E5%90%8C%E7%9A%84%E5%8D%B7%E7%A7%AF%E6%A0%B8%E8%83%BD%E5%A4%9F%E6%8F%90%E5%8F%96%E5%9B%BE%E7%89%87%E7%9A%84%E4%B8%8D%E5%90%8C%E7%89%B9%E5%BE%81.PNG"></p>
<p>卷积神经网络保持平移、缩放、变形不变性的原因：</p>
<ul>
<li><strong>局部感受野</strong>    每个神经元仅与输入神经元的一块区域连接，这块局部区域称作感受野（receptive field）。局部连接的思想，也是受启发于生物学里面的视觉系统结构，视觉皮层的神经元就是局部接受信息的。</li>
<li><strong>权值共享</strong>    卷积核是共享的</li>
<li><strong>下采样、池化</strong>    减少参数，防止过拟合</li>
</ul>
<p><strong>1 x 1 卷积的作用：</strong></p>
<ol>
<li>降维或升维</li>
<li>跨通道信息交融</li>
<li>减少参数量（减少运算量）</li>
<li>增加模型深度，提高非线性表示能力</li>
</ol>
<p><strong>目前神经网络发展的趋势：</strong>更小的卷积核，更深的网络。更少的池化层和全连接层，以减少信息的丢失，使用全卷积网络（FCN）。</p>
<p><strong>相关演示网页：</strong> <a target="_blank" rel="noopener" href="https://cs.stanford.edu/people/karpathy/convnetjs/demo/cifar10.html">cifar10</a>    <a target="_blank" rel="noopener" href="https://transcranial.github.io/keras-js/#/mnist-cnn">MNIST</a>    <a target="_blank" rel="noopener" href="http://yosinski.com/deepvis#toolbox">Visualizing Activations</a>        <a target="_blank" rel="noopener" href="http://projector.tensorflow.org/">Other</a> </p>
<h3 id="相关资料"><a href="#相关资料" class="headerlink" title="相关资料"></a>相关资料</h3><p>[1]. 课程官方地址：<a target="_blank" rel="noopener" href="http://cs231n.stanford.edu/syllabus.html">http://cs231n.stanford.edu/syllabus.html</a></p>
<p>[2]. 哔哩哔哩课程视频地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/av76633310?p=5">https://www.bilibili.com/video/av76633310?p=5</a></p>
<p>[3]. 官方笔记的中文翻译（2016年版）：<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/21930884">https://zhuanlan.zhihu.com/p/21930884</a></p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">清欢</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://lijitao.top/2021/11/13/si-tan-fu-li-fei-fei-jiao-shou-ji-suan-ji-shi-jue-ke-cheng/">https://lijitao.top/2021/11/13/si-tan-fu-li-fei-fei-jiao-shou-ji-suan-ji-shi-jue-ke-cheng/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">清欢</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">
                                    <span class="chip bg-color">机器学习</span>
                                </a>
                            
                                <a href="/tags/Python/">
                                    <span class="chip bg-color">Python</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2021/11/13/wu-lian-wang-ji-zhu-zai-nong-ye-zhong-de-ying-yong/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/0.jpg" class="responsive-img" alt="">
                        
                        <span class="card-title"></span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2021-11-13
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            清欢
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2021/11/13/jie-jue-hexo-dong-tai-bei-jing-da-kai-wu-xiao-guo/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/0.jpg" class="responsive-img" alt="">
                        
                        <span class="card-title"></span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            title: 解决Hexo动态背景打开无效果categories: 

前端tags:
博客
hexo

目前Hexo内置了两个动态背景效果，但是修改配置文件后却不显示效果。
解决方案：
查看官方文档并按步骤操作。
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-11-13
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            清欢
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4, h5, h6'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4, h5, h6').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    

    <div class="container row center-align"
         style="margin-bottom: 15px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2020-2022</span>
            
            <a href="/about" target="_blank">清欢</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            
            
                
            
            
                <span id="busuanzi_container_site_pv">
                &nbsp;|&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;
                    <span id="busuanzi_value_site_pv" class="white-color"></span>
            </span>
            
            
                <span id="busuanzi_container_site_uv">
                &nbsp;|&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;
                    <span id="busuanzi_value_site_uv" class="white-color"></span>
            </span>
            
            <br>

            <!-- 运行天数提醒. -->
            
                <span id="sitetime"> Loading ...</span>
                <script>
                    var calcSiteTime = function () {
                        var seconds = 1000;
                        var minutes = seconds * 60;
                        var hours = minutes * 60;
                        var days = hours * 24;
                        var years = days * 365;
                        var today = new Date();
                        var startYear = "2020";
                        var startMonth = "11";
                        var startDate = "21";
                        var startHour = "0";
                        var startMinute = "0";
                        var startSecond = "0";
                        var todayYear = today.getFullYear();
                        var todayMonth = today.getMonth() + 1;
                        var todayDate = today.getDate();
                        var todayHour = today.getHours();
                        var todayMinute = today.getMinutes();
                        var todaySecond = today.getSeconds();
                        var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                        var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                        var diff = t2 - t1;
                        var diffYears = Math.floor(diff / years);
                        var diffDays = Math.floor((diff / days) - diffYears * 365);

                        // 区分是否有年份.
                        var language = 'zh-CN';
                        if (startYear === String(todayYear)) {
                            document.getElementById("year").innerHTML = todayYear;
                            var daysTip = 'This site has been running for ' + diffDays + ' days';
                            if (language === 'zh-CN') {
                                daysTip = '本站已运行 ' + diffDays + ' 天';
                            } else if (language === 'zh-HK') {
                                daysTip = '本站已運行 ' + diffDays + ' 天';
                            }
                            document.getElementById("sitetime").innerHTML = daysTip;
                        } else {
                            document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                            var yearsAndDaysTip = 'This site has been running for ' + diffYears + ' years and '
                                + diffDays + ' days';
                            if (language === 'zh-CN') {
                                yearsAndDaysTip = '本站已运行 ' + diffYears + ' 年 ' + diffDays + ' 天';
                            } else if (language === 'zh-HK') {
                                yearsAndDaysTip = '本站已運行 ' + diffYears + ' 年 ' + diffDays + ' 天';
                            }
                            document.getElementById("sitetime").innerHTML = yearsAndDaysTip;
                        }
                    }

                    calcSiteTime();
                </script>
            
            <br>
            
                <span id="icp"><img src="/medias/icp.png"
                                    style="vertical-align: text-bottom;"/>
                <a href="http://beian.miit.gov.cn/" target="_blank">鲁ICP备19005295号-2</a>
            </span>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/jinxiqinghuan" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:1196680037@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>





    <a href="https://twitter.com/realljt" class="tooltipped" target="_blank" data-tooltip="关注我的Twitter: https://twitter.com/realljt" data-position="top" data-delay="50">
        <i class="fab fa-twitter"></i>
    </a>



    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1196680037" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1196680037" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    

    

    <!-- 雪花特效 -->
     
        <script type="text/javascript">
            // 只在桌面版网页启用特效
            var windowWidth = $(window).width();
            if (windowWidth > 768) {
                document.write('<script type="text/javascript" src="/libs/others/snow.js"><\/script>');
            }
        </script>
    

    <!-- 鼠标星星特效 -->
    

     
        <script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>
        <script src="/libs/others/TencentCaptcha.js"></script>
        <button id="TencentCaptcha" data-appid="xxxxxxxxxx" data-cbfn="callback" type="button" hidden></button>
    

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
